home *** CD-ROM | disk | FTP | other *** search
- Path: news.halcyon.com!usenet
- From: normanb@halcyon.com (Norm Bryar)
- Newsgroups: comp.lang.c++
- Subject: Re: I need some help with a homework
- Date: Mon, 19 Feb 1996 18:56:52 GMT
- Organization: Northwest Nexus Inc.
- Message-ID: <4gah4i$907@news.halcyon.com>
- References: <4g8o4f$m93@ixnews7.ix.netcom.com>
- NNTP-Posting-Host: blv-pm12-ip19.halcyon.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- Comments prefaced by <=======
-
- --Norm
-
- lewkbj@ix.netcom.com (leonel wizel ) wrote:
-
- >....
-
- >The program suppose to
-
- >Enter hours worked (-1 to end): 39
- >enter hourly rate of the worker ($00:00): 10.00
- >salary is $390.00
-
- >Enter hours worked (-1 to end): 40
- >enter hourly rate of the worker ($00:00): 10.00
- >salary is $400.00
-
- >...
- >the following program I wrote but, only gives me one amout which is
- >$390.00, it supposse to give me the second amount which is 400.00
- >but, it keeps repeating the same figure which is 390.00
-
-
- >#include <iostream.h>
- >#include <iomanip.h>
-
- >main()
- >{
- >//initialization phase
-
- >float hour_rate, salary, hours_worked;
-
-
- >cout << "Enter hours worked (-1 to end): ";
- >cin >> hours_worked;
-
- > if (hours_worked != 1) <========= -1?
- > {
- > cout << "Enter hourly rate of the worker ($00.00): ";
- > cin >> hour_rate;
- > }
-
- >//processing phase
- >
- > while (hours_worked != -1)
- > {
- > if (hours_worked > 40)
- > {
- > salary = hours_worked * hour_rate +
- > (hour_worked * 1.5 * hour_rate); <=========(hours_worked-40)*1.5?
- > }
- > else
- > salary = hours_worked * hour_rate;
-
- > cout << "The salary for the employee is: \n"
- > << setiosflags(ios::fixed | ios::showpoint)
- > << setprecision(2) << salary << endl;
-
- > cout << endl;
-
- > cout <<"Enter hours worked (-1 to end): ";
- > cin >> hour_rate; <========= hours_worked !!!
-
- > if (hours_worked != -1)
- > {
- > cout << "Enter hourly rate of the worker ($00.00): ";
- > cin >> hour_rate;
- > }
- > }
-
- >//termination phase
-
- >if (hours_worked == -1)
- > {
- > cout << endl;
- > cout << "no hours were entered";
- > }
-
- >return 0;
- >}
-
- >...
- >Thank you.
-
-
-
-
-